#pragma once
#include<vector>
#include"Singleton.h"
#include<boost/asio.hpp>


class AsioIOServicePool:public Singleton<AsioIOServicePool>
{

	friend Singleton<AsioIOServicePool>;
public:
	using IOService = boost::asio::io_context;
	using WORK = boost::asio::io_context::work;
	using WorkPtr = std::unique_ptr<WORK>;
	~AsioIOServicePool();
	AsioIOServicePool(const AsioIOServicePool&) = delete;
	AsioIOServicePool& operator = (const AsioIOServicePool&) = delete;

	boost::asio::io_context& GetIOservice();

	void Stop();

private:

	AsioIOServicePool(std::size_t size = 2);
	std::vector<IOService> _ioService;
	std::vector<WorkPtr> _work;
	std::vector<std::thread> _thread; 
	std::size_t _nextIOService;
};

